package com.example.thegreatwall.controller;


import org.springframework.stereotype.Component;

import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * 摇一摇
 */
@ServerEndpoint(value = "/qrsocket/{openid}")
@Component
public class WxSocket {
    public static Map<String,Session>wxSessionMap=new HashMap<>();
    public WxSocket() {
        System.out.println("实例化websocketwx是多例模式的");
    }

    @OnOpen
    public void onopen(Session session, @PathParam("openid") String openid) throws IOException {
        System.out.print("openid==="+openid);
        wxSessionMap.put(openid,session);
    }
}
